package DoublyLinkedListSentinel2;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.List;

public class DoublyLinkedListSentinel2Test {
      DoublyLinkedListSentinel2 list = new DoublyLinkedListSentinel2();
    @Test
    void addFirst() {
        list.addFirst(1);
        list.addFirst(2);
        list.addFirst(3);
        list.addFirst(4);
      Assertions.assertIterableEquals(List.of(4,3,2,1),list
      );
    }

    @Test
    void addLast() {
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);
        list.addLast(4);
        Assertions.assertIterableEquals(List.of(1,2,3,4),list);
    }

    @Test
    void removeFirst() {
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);
        list.addLast(4);
        list.removeFirst();
        Assertions.assertIterableEquals(List.of(2,3,4),list);
    }

    @Test
    void removeLast() {
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);
        list.addLast(4);
        list.removeLast();
        Assertions.assertIterableEquals(List.of(1,2,3),list);
    }

    @Test
    void removeByValue() {
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);
        list.addLast(4);
        list.removeByValue(2);
        Assertions.assertIterableEquals(List.of(1,3,4),list);
        System.out.println("-----------------");
        list.removeByValue(1);
        Assertions.assertIterableEquals(List.of(3,4),list);
        System.out.println("-----------------");
        list.removeByValue(3);
        Assertions.assertIterableEquals(List.of(4),list);
        System.out.println("-----------------");
        list.removeByValue(4);
        Assertions.assertIterableEquals(List.of(),list);
    }
}
